import { CategroySplitItem, CreateSplitParams } from './type';

export * from './type';
/**
 * 创建类目拆分
 * @param data
 * @returns
 */
export const createCategorySplit = (data: CreateSplitParams) =>
  post(Prefix.api + '/category-split', data);

/**
 * 获取已拆分的类目
 * @param params
 * @returns
 */
export const getCategorySplits = (params: { websiteCode: string }) =>
  get<CategroySplitItem[]>(Prefix.api + '/category-split/list', params);

/**
 * 修改类目拆分
 * @param data
 * @returns
 */
export const modifyCategorySplits = (data: CreateSplitParams) =>
  put(Prefix.api + '/category-split', data);

/**
 * 类目拆分发布
 * @param websiteCode
 * @param categoryCode
 * @returns
 */
export const publishSplits = (websiteCode: string, categoryCode: string) =>
  put(
    Prefix.api + '/category-split/publish',
    {},
    {
      params: {
        websiteCode,
        categoryCode,
      },
    }
  );

/**
 * 类目拆分删除
 * @param websiteCode
 * @param categoryCode
 * @returns
 */
export const removeCategorySplits = (
  websiteCode: string,
  categoryCode: string
) =>
  del(Prefix.api + '/category-split', {
    websiteCode,
    categoryCode,
  });

/**
 * 类目发布
 * @param categoryCode
 * @returns
 */
export const categoryPublish = (categoryCode: string) =>
  put(Prefix.api + '/category/publish/' + categoryCode);

/**
 * 类目取消发布
 * @param categoryCode
 * @returns
 */
export const categoryCancel = (categoryCode: string) =>
  put(Prefix.api + '/category/cancel-publish/' + categoryCode);
